package com.sky.service.common.impl;

import com.sky.constant.MessageConstant;
import com.sky.exception.ParameterIsNullException;
import com.sky.mapper.common.MerchantMapper;
import com.sky.pojo.Merchant;
import com.sky.service.common.MerchantService;
import com.sky.vo.ShopVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Objects;

/**
 * 商家业务实现
 * @author zgp
 * @version V1.0
 * @date 2025-01-27 14:40
 */
@Service
public class MerchantServiceImpl implements MerchantService {
    @Autowired
    private MerchantMapper merchantMapper;

    @Override
    public ShopVO getMerchantInfo(Long id) {
        // 校验参数
        if(Objects.isNull(id)){
            throw new ParameterIsNullException(MessageConstant.PARAMES_IS_INVALID);
        }
        Merchant merchant = merchantMapper.selectById(id);
        ShopVO shopVo = ShopVO.builder()
                .id(merchant.getId())
                .phone(merchant.getShopTelephone())
                .shopAddress(merchant.getShopAddress())
                .shopName(merchant.getShopName())
                .build();
        return shopVo;
    }
}
